import queue
import threading
import time

class put(threading.Thread):
    def __init__(self,q):
        self.q=q
        self.index=0
        super(put,self).__init__()

    def run(self):
        while True:
            self.index+=1
            self.q.put(self.index)
            time.sleep(1)

class get(threading.Thread):
    def __init__(self,q):
        self.q=q
        super(get,self).__init__()

    def run(self):
        while True:
            # 会弹出get的东西，从队列里
            print(self.q.get())

if __name__=="__main__":
    q=queue.Queue(5)
    t1=put(q)
    t2=get(q)
    t1.start()
    t2.start()